package com.hyny.framework.platform.system.controller;

import cn.hutool.core.util.StrUtil;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;

import com.hyny.framework.platform.system.annotation.Log;
import com.hyny.framework.platform.system.entity.param.LoginParam;
import com.hyny.framework.platform.system.service.ILoginService;
import com.hyny.framework.platform.system.utils.bean.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


@Api(tags = "授权登录")
@ApiSupport(order=1)
@RestController
public class LoginController {
    @Autowired
    private ILoginService iLoginService;

    @ApiOperation(value = "系统登录",notes = "系统登录")
    @PostMapping("/login")
    @Log("登录")
    public Result login(@RequestBody LoginParam loginParam){
        if (StrUtil.isEmpty(loginParam.getUserName())) {
            return Result.error("用户名不能为空！");
        }
        if (StrUtil.isEmpty(loginParam.getPassword())) {
            return Result.error("密码不能为空！");
        }
       return iLoginService.login(loginParam);
    }



    //登出操作
    @ApiOperation(value = "退出",notes = "退出聚合平台")
    @PostMapping("/logout")
    @Log("登出")
    public Result logout() {
        return Result.ok();
    }
}
